import threading
import time

def worker(num):
  print (threading.currentThread().getName() + ' start') 
  time.sleep(10)
  print (threading.currentThread().getName() + ' running')
  print (threading.currentThread().getName() + " " + str(num))
  print (threading.currentThread().getName() + ' exit')
  
def deamon():
  print (threading.currentThread().getName() + ' start')
  time.sleep(20)
  print (threading.currentThread().getName() + ' running')
  print (threading.currentThread().getName() + ' exit')
  
print(threading.currentThread().getName())

d = threading.Thread(name='deamon', target=deamon)
d.setDaemon(True)
d.start()

w = threading.Thread(name='worker', target=worker, args=(10,))
w.start()

class myWorker(threading.Thread):
    def __init__(self, num):  
        threading.Thread.__init__(self)  
        self.num = num  
        self.thread_stop = False  
   
    def run(self): 
        print (self.getName()+' start')
        time.sleep(30)
        print (self.getName()+' running')
        print (self.getName()+" " + str(self.num))
        print (self.getName()+' exit')
 
mw = myWorker(30)
mw.setName("MyWorker")
mw.start()

print(threading.currentThread().getName())

print("All threads:")
print("------------")
for th in threading.enumerate():
  print(th.getName())
print("------------")

d.join()
w.join()
mw.join()

print(threading.currentThread().getName())